﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OptikinetiqControls
{

    public delegate void SelectDelegate(Display sender);

    public partial class Display : UserControl
    {
        public event SelectDelegate selectEvent;

        [DisplayName("MyCustom")]
        [Description("显示图片")]
        /// <summary>
        /// 显示图片
        /// </summary>
        public Bitmap image {
            get {
                if (pictureBox.Image == null) {
                    return null;
                }
                return pictureBox.Image as Bitmap; 
            
            }
            set { pictureBox.Image = value; }
        }


        /// <summary>
        /// 信息
        /// </summary>
        [DisplayName("MyCustom")]
        [Description("图片信息")]
        public string info {
            get
            {
                return label_info.Text;
            }
            set { label_info.Text = value; }
        }


        public Display()
        {
            InitializeComponent();
        }

        public Display(Bitmap image, string info) {
            InitializeComponent();
            this.image = image;
            this.info = info;
        }

        private void pictureBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            selectEvent?.Invoke(this);
        }
    }
}
